<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>西大网上书城 - 添加图书</title>
    <link rel="stylesheet" href="css/bookstore.css" />
    <style>
        :root {
            --primary: #336699;
            --primary-dark: #2a5980;
            --success: #27ae60;
            --white: #ffffff;
            --dark-text: #333333;
            --light-text: #666666;
            --border: #dddddd;
        }

        /* 添加图书页面特定样式 */
        body {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        .container {
            width: 100%;
            max-width: 600px;
            animation: fadeIn 0.8s ease-out;
        }

        .logo {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            margin-bottom: 20px;
        }

        .logo-icon {
            font-size: 32px;
            color: white;
        }

        .logo h1 {
            font-size: 28px;
            color: white;
            font-weight: 600;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }

        .page-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .page-header h2 {
            font-size: 24px;
            color: white;
            margin-bottom: 10px;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }

        .page-header p {
            color: rgba(255, 255, 255, 0.8);
        }

        .form-card {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            padding: 40px 30px;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            backdrop-filter: blur(10px);
        }

        .form-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: var(--dark-text);
            font-weight: 500;
            font-size: 14px;
        }

        .form-control {
            width: 100%;
            padding: 14px 15px;
            border: 1px solid var(--border);
            border-radius: 8px;
            font-size: 15px;
            transition: all 0.3s;
            background-color: #f8f9fa;
        }

        .form-control:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(51, 102, 153, 0.1);
            background-color: var(--white);
        }

        textarea.form-control {
            min-height: 100px;
            resize: vertical;
        }

        .file-input-container {
            position: relative;
            overflow: hidden;
            display: inline-block;
            width: 100%;
        }

        .file-input {
            position: absolute;
            left: 0;
            top: 0;
            opacity: 0;
            width: 100%;
            height: 100%;
            cursor: pointer;
        }

        .file-input-label {
            display: block;
            padding: 14px 15px;
            background-color: #f8f9fa;
            border: 1px dashed var(--border);
            border-radius: 8px;
            text-align: center;
            color: var(--light-text);
            cursor: pointer;
            transition: all 0.3s;
        }

        .file-input-label:hover {
            background-color: #e9ecef;
            border-color: var(--primary);
            color: var(--primary);
        }

        .file-name {
            display: block;
            margin-top: 8px;
            font-size: 14px;
            color: var(--light-text);
            word-break: break-all;
        }

        .btn-submit {
            width: 100%;
            padding: 15px;
            background: linear-gradient(135deg, var(--success) 0%, #219653 100%);
            color: var(--white);
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            margin-top: 10px;
            box-shadow: 0 4px 10px rgba(39, 174, 96, 0.2);
        }

        .btn-submit:hover {
            background: linear-gradient(135deg, #219653 0%, var(--success) 100%);
            box-shadow: 0 6px 15px rgba(39, 174, 96, 0.3);
            transform: translateY(-2px);
        }

        .btn-submit:active {
            transform: scale(0.98);
        }

        .form-footer {
            text-align: center;
            margin-top: 25px;
        }

        .form-footer a {
            color: var(--primary);
            text-decoration: none;
            transition: color 0.2s;
            font-size: 14px;
        }

        .form-footer a:hover {
            color: var(--primary-dark);
            text-decoration: underline;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        @media (max-width: 480px) {
            .form-card {
                padding: 30px 20px;
            }

            .logo h1 {
                font-size: 24px;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <div class="logo">
        <span class="logo-icon">📚</span>
        <h1>西大网上书城</h1>
    </div>

    <div class="page-header">
        <h2>添加图书</h2>
        <p>请输入图书信息</p>
    </div>

    <div class="form-card">
        <form action="./addBook" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label for="name">书名</label>
                <input type="text" id="name" name="name" class="form-control" placeholder="请输入书名" required>
            </div>

            <div class="form-group">
                <label for="author">作者</label>
                <input type="text" id="author" name="author" class="form-control" placeholder="请输入作者" required>
            </div>

            <div class="form-group">
                <label for="price">价格</label>
                <input type="text" id="price" name="price" class="form-control" placeholder="请输入价格" required>
            </div>

            <div class="form-group">
                <label for="memo">备注</label>
                <textarea id="memo" name="memo" class="form-control" placeholder="请输入备注信息"></textarea>
            </div>

            <div class="form-group">
                <label for="publish">出版日期</label>
                <input type="text" id="publish" name="publish" class="form-control" placeholder="请输入出版日期，格式：YYYY-MM-DD" required>
            </div>

            <div class="form-group">
                <label for="picture">图书图片</label>
                <div class="file-input-container">
                    <input type="file" id="picture" name="picture" class="file-input" accept="image/*">
                    <label for="picture" class="file-input-label">选择图片文件</label>
                </div>
                <span class="file-name" id="fileName">未选择文件</span>
            </div>

            <button type="submit" class="btn-submit">添加图书</button>
        </form>

        <div class="form-footer">
            <a href="./books">← 返回图书列表</a>
        </div>
    </div>
</div>

<script>
    document.getElementById('picture').addEventListener('change', function(e) {
        const fileName = e.target.files.length > 0 ? e.target.files[0].name : '未选择文件';
        document.getElementById('fileName').textContent = fileName;
    });
</script>
</body>
</html>